package lily.ui.control;

import lily.phs.urh.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;



public class SquareItemAdapter extends BaseAdapter{
	Context context;
	TextView tvName;
	String name[];
	int image[];

	public SquareItemAdapter(Context arg2,String n[],int i[]){
		this.context = arg2;
		this.name=n;
		this.image=i;
	}

	@Override
	public int getCount(){
		return name.length;
	}

	@Override
	public Object getItem(int paramInt){
		return Integer.valueOf(paramInt);
	}

	@Override
	public long getItemId(int paramInt){
		return paramInt;
	}

	@Override
	public View getView(int paramInt, View paramView, ViewGroup paramViewGroup){
		ViewHolder mViewHolder;
		if(paramView==null){
			paramView = ((LayoutInflater)this.context.getSystemService(context.LAYOUT_INFLATER_SERVICE))
				.inflate(R.layout.square_item_view, null);
			mViewHolder= new ViewHolder();
			mViewHolder.tv = (TextView)paramView.findViewById(R.id.tvItemName);
			mViewHolder.iv=(ImageView)paramView.findViewById(R.id.chufang_image);
			paramView.setTag(mViewHolder);
		}
		else{
			mViewHolder=(ViewHolder)paramView.getTag();
		}
		
		
		if (paramInt == 0){
			String str1 = name[0];
			mViewHolder.tv.setText(str1);
			paramView.setBackgroundResource(R.drawable.circle_list);
			mViewHolder.iv.setImageResource(image[0]);
		}
		else {
			String str1 = name[paramInt];
			mViewHolder.tv.setText(str1);
			paramView.setBackgroundResource(R.drawable.circle_list);
			mViewHolder.iv.setImageResource(image[1]);
		}

		

		return paramView;
	}
	
	class ViewHolder
	{
		ImageView iv;
		TextView tv;

		ViewHolder()
		{
		}
	}
}

